//===================================================================
// 项目名 : Hbt.Cur
// 文件名 : IHbtWorkflowScheduler.cs
// 创建者 : Claude
// 创建时间: 2024-12-01
// 版本号 : V0.0.1
// 描述    : 工作流定时任务调度器接口
//===================================================================

using Hbt.Application.Dtos.Workflow;

namespace Hbt.Application.Services.Workflow.Engine.Scheduler
{
    /// <summary>
    /// 工作流定时任务调度器接口
    /// </summary>
    public interface IHbtWorkflowScheduler
    {
        /// <summary>
        /// 创建定时任务
        /// </summary>
        /// <param name="dto">定时任务配置</param>
        /// <returns>定时任务ID</returns>
        Task<string> CreateScheduledTaskAsync(HbtWorkflowScheduledTaskDto dto);

        /// <summary>
        /// 更新定时任务
        /// </summary>
        /// <param name="taskId">任务ID</param>
        /// <param name="dto">更新配置</param>
        /// <returns>是否成功</returns>
        Task<bool> UpdateScheduledTaskAsync(string taskId, HbtWorkflowScheduledTaskDto dto);

        /// <summary>
        /// 删除定时任务
        /// </summary>
        /// <param name="taskId">任务ID</param>
        /// <returns>是否成功</returns>
        Task<bool> DeleteScheduledTaskAsync(string taskId);

        /// <summary>
        /// 暂停定时任务
        /// </summary>
        /// <param name="taskId">任务ID</param>
        /// <returns>是否成功</returns>
        Task<bool> PauseScheduledTaskAsync(string taskId);

        /// <summary>
        /// 恢复定时任务
        /// </summary>
        /// <param name="taskId">任务ID</param>
        /// <returns>是否成功</returns>
        Task<bool> ResumeScheduledTaskAsync(string taskId);

        /// <summary>
        /// 获取定时任务列表
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <returns>定时任务列表</returns>
        Task<HbtPagedResult<HbtWorkflowScheduledTaskDto>> GetScheduledTasksAsync(HbtWorkflowScheduledTaskQueryDto query);

        /// <summary>
        /// 获取定时任务详情
        /// </summary>
        /// <param name="taskId">任务ID</param>
        /// <returns>定时任务详情</returns>
        Task<HbtWorkflowScheduledTaskDto?> GetScheduledTaskAsync(string taskId);

        /// <summary>
        /// 立即执行定时任务
        /// </summary>
        /// <param name="taskId">任务ID</param>
        /// <returns>是否成功</returns>
        Task<bool> ExecuteScheduledTaskNowAsync(string taskId);

        /// <summary>
        /// 检查工作流超时
        /// </summary>
        /// <param name="instanceId">工作流实例ID</param>
        /// <returns>是否超时</returns>
        Task<bool> CheckWorkflowTimeoutAsync(long instanceId);

        /// <summary>
        /// 处理工作流超时
        /// </summary>
        /// <param name="instanceId">工作流实例ID</param>
        /// <param name="timeoutAction">超时动作</param>
        /// <returns>是否处理成功</returns>
        Task<bool> HandleWorkflowTimeoutAsync(long instanceId, string timeoutAction);

        /// <summary>
        /// 获取超时配置
        /// </summary>
        /// <param name="schemeId">流程定义ID</param>
        /// <returns>超时配置</returns>
        Task<HbtWorkflowTimeoutConfigDto?> GetTimeoutConfigAsync(long schemeId);
    }
}
